/**
 * 巡检api接口
 */
// http
import {
	http
} from '../request/service-patrol.js';



/**
 * @param {Object} fromData
 * 用户登录
 */
function login(fromData) {
	return http.get('auth/login', {
		params: fromData
	})
}

/**
 * 获取用户信息
 */
function getUserInfo() {
	return http.get('org/employees/info', {});
}

/**
 * 获取移动巡检列表
 */
function getPatrolMobileList(userId) {
	return http.get('mcs/app/app_patrol_mobile_check', {
		params: {
			userId: userId
		}
	});
}

/**
 * 获取移动巡检详情
 */
function getPatrolMobileInfo(projectId, userId) {
	return http.get("mcs/app/app_patrol_mobile_check/" + projectId, {
		params: {
			userId: userId
		}
	});
}

/**
 * 上传移动巡检数据
 * @param {Object} record
 */
function uploadMobileRecord(record) {
	return http.post('mcs/app/app_patrol_mobile_check_records', record);
}



/**
 * 获取设备巡检详情
 * @param {Object} code
 * @param {Object} userId
 */
function getPatrolDeviceInfo(code, userId) {
	return http.get("mcs/app/app_patrol_facility_check", {
		params: {
			markCode: code,
			userId: userId
		}
	});
}

/**
 * 设备巡检记录上传
 * @param {Object} record
 */
function uploadDeviceRecord(record) {
	return http.post('mcs/app/app_patrol_facility_check_records', record);
}

/**
 * 上传巡检附件
 * @param {Object} dangerId
 * @param {Object} employeeName
 * @param {Object} files
 */
function uploadPatrolFile(dangerId, employeeName, path) {
	return http.upload('mcs/app/app_patrol_facility_check_records/app_upload', {
		formData: {
			dangerId: dangerId,
			employeeName: employeeName
		},
		filePath: path,
		name: 'file'
	});
}

/**
 * 获取工程巡检历史记录
 * @param {Object} start
 * @param {Object} end
 */
function getMobileHistory(start, end) {
	return http.get('mcs/app/app_patrol_mobile_check_records', {
		params: {
			startTime: start,
			endTime: end
		}
	});
}


/**
 * 更具id获取工程巡检历史详情
 * @param {Object} id
 */
function getMobileHistoryInfo(id) {
	return http.get('mcs/app/app_patrol_mobile_check_records/' + id, {});
}


/**
 * 获取设备巡检历史记录
 * @param {Object} start
 * @param {Object} end
 */
function getDeviceHistory(start, end) {
	return http.get('mcs/app/app_patrol_facility_check_records', {
		params: {
			startTime: start,
			endTime: end
		}
	});
}

/**
 * 更具id获取设备巡检历史记录
 * @param {Object} id
 */
function getDeviceHistoryInfo(id) {
	return http.get('mcs/app/app_patrol_facility_check_records/' + id, {});
}


/**
 * 获取隐患列表
 */
function getDangerList(pageIndex, pageSize) {
	return http.get('mcs/app/maintenance_defect_info/page', {
		params: {
			pageIndex: pageIndex,
			pageSize: pageSize,
			processStep: ''
		}
	})
}

/**
 * 获取处理隐患流程列表
 * @param {Object} id
 */
function getDangerFlowList(id) {
	return http.get('mcs/app/maintenance_defect_tracking_info/' + id, {});
}




export default {
	login,
	getUserInfo,
	getPatrolMobileList,
	getPatrolMobileInfo,
	getPatrolDeviceInfo,
	uploadPatrolFile,
	uploadMobileRecord,
	uploadDeviceRecord,
	getMobileHistory,
	getMobileHistoryInfo,
	getDeviceHistory,
	getDeviceHistoryInfo,
	getDangerList,
	getDangerFlowList
}
